#! /bin/bash
NOW_DIR=$(cd -P $(dirname $0);pwd)
WWW_DIR=/home/www/
DOCKER_DIR=$NOW_DIR

chmod -R 777 "${WWW_DIR}"

#开启站点
WebKeyArr=$@

WebArr=(dev.au.callie.com dev.ca.callie.com dev.fr.callie.com dev.uk.callie.com dev.www.callie.com dev.www.callie.de dev.it.callie.com dev.nl.callie.com dev.www.callie.es dev1.www.callie.com dev1.www.callie.de);

# 遍历数组并获取键和值
for index in "${!WebArr[@]}"; do
  key="$index"
  value="${WebArr[$index]}"
  echo "键：$key，值：$value"
  if [[ ! " ${WebKeyArr[*]} " =~ " $key " ]]; then
    echo "$value 站点不启动"
    continue
  fi
  echo "$value 站点准备启动"
  #docker站点目录
  siteDockerDir=${DOCKER_DIR}/$value
  chmod -R 777 "${DOCKER_DIR}"
  #授权files文件夹只读
  echo "开始授权files文件夹只读"
  chmod -R 644 "${siteDockerDir}/files/mysql5.7.18"
  chmod -R 644 "${siteDockerDir}/files/mariadb10.6.11"
  echo "开始启动站点"
  cd "${siteDockerDir}" && docker-compose up -d
  echo "启动 ${value} 站点成功！！！"
done
